package Algorithm.math;

/**
 * @Desc:
 * @author: cww
 * @DateTime: 2020-06-07 14:12
 */

public class Divide {
    public static void main(String[] args) {
        System.out.println(divide(10,3));
    }

    public static int divide(int dividend, int divisor) {
        if(dividend == Integer.MAX_VALUE&&divisor==-1) return dividend;
        boolean same = (dividend>0 && divisor>0)||(dividend<0&&divisor<0);
        int ans = 0;
        dividend = - Math.abs(dividend);
        divisor = - Math.abs(divisor);
        while(dividend<=divisor){
            dividend -= divisor;
            ans++;
        }
        return same? ans:-ans;
    }
}
